T
CSharpTest.Net
ReadOnlyList<T> Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ReadOnlyList<T> Class

Glossary Item Box

A readonly list of T

Object Model

ReadOnlyList<T> ClassT Class

Syntax

Visual Basic (Declaration) 
Public Class ReadOnlyList(Of T) 
   Implements IReadOnlyCollection(Of T)CSharpTest.Net.Interfaces.ICloneable(Of ReadOnlyList(Of T)) 

Type Parameters

T

Example

Library/Library.Test/TestReadOnlyList.cs

C#Copy Code
ICollection read = new ReadOnlyList<int>((IEnumerable<int>)new int[] { 5, 10, 15 });
Assert.AreEqual(3, read.Count);
Assert.IsFalse(read.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(read, read.SyncRoot));

long[] lary = new long[3];
read.CopyTo(lary, 0);
Assert.AreEqual(5L, lary[0]);
Assert.AreEqual(10L, lary[1]);
Assert.AreEqual(15L, lary[2]);

ICollection copy = (ICollection)((ICloneable)read).Clone();
Assert.AreEqual(3, copy.Count);
VB.NETCopy Code
Dim read As ICollection = New ReadOnlyList(Of Integer)(DirectCast(New Integer() {5, 10, 15}, IEnumerable(Of Integer)))
Assert.AreEqual(3, read.Count)
Assert.IsFalse(read.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(read, read.SyncRoot))

Dim lary As Long() = New Long(3) {}
read.CopyTo(lary, 0)
Assert.AreEqual(5L, lary(0))
Assert.AreEqual(10L, lary(1))
Assert.AreEqual(15L, lary(2))

Dim copy As ICollection = DirectCast((DirectCast(read, ICloneable)).Clone(), ICollection)
Assert.AreEqual(3, copy.Count)

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Collections.ReadOnlyList<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys